<template>
  <el-drawer
      title="Account List"
      size="60%"
      :visible.sync="accountList"
      :wrapperClosable=false
      :destroy-on-close=true
      @close="handleClose">
    <el-row style="padding: 0 24px">
      <el-button type="primary" style="margin-bottom: 12px" @click="handleAdd">Add</el-button>
      <div class="tab-box">
        <el-table :data="tableData" fit style="width: 100%">
          <el-table-column prop="Username" label="Username" min-width="200"></el-table-column>
          <el-table-column label="Type" width="250">
            <template slot-scope="scope">
              {{ scope.row.Type === 1 ? 'Super Administrator' : 'Ordinary Administrator' }}
            </template>
          </el-table-column>
          <el-table-column label="Last Login Time" width="200">
            <template slot-scope="scope">
              {{ day(scope.row.UpdatedAt).format('YYYY-MM-DD HH:mm:ss') }}
            </template>
          </el-table-column>
          <el-table-column label="Operate" width="120" align="center">
            <template slot-scope="scope">
              <el-button type="text" style="color:#f56c6c" @click="onDelete(scope.row.ID)">Delete</el-button>
            </template>
          </el-table-column>
        </el-table>
      </div>
    </el-row>
    <Info ref="info" @init="init"/>
  </el-drawer>
</template>
<script>
import day from 'dayjs'
import Info from './info'

export default {
  data() {
    return {
      accountList: false,
      tableData: []
    }
  },
  components: {
    Info
  },
  methods: {
    day,
    async init() {
      this.accountList = true
    },
    handleClose() {
      this.accountList = false
    },
    async handleAdd() {
      this.$refs.info.init()
    },
    async onDelete(accountId) {

    }
  }
}
</script>
<style lang="less" scoped>
.pagination {
  width: 100%;
  text-align: right;
}

.delete {
  margin-left: 12px;
  color: #409EFF;
  cursor: pointer
}

.delete:hover {
  color: #f56c6c
}
</style>
